home *** CD-ROM | disk | FTP | other *** search
/ The Best of MacTutor - S…e Code for Volumes 1 to 5 / The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin / Source Code / #27 (Dec 87) / c daisy printer driver / prglobals.h < prev    next >
Text File  |  1987-09-29  |  4KB  |  186 lines

  1.  
  2. #define nil 0L
  3. #include <PrintMgr.h>
  4. #include <DeviceMgr.h>
  5. #include <FileMgr.h>
  6. #include <Environs.h>
  7. #define    DIRTY    0xFFFF
  8. /* LightspeedC doesn't do this exactly right for a Printer control call. */
  9. typedef struct
  10.     {
  11.     QElemPtr    qLink;
  12.     int        qType;
  13.     int        ioTrap;
  14.     Ptr        ioCmdAddr;
  15.     ProcPtr        ioCompletion;
  16.     OsErr        ioResult;
  17.     StringPtr    ioNamePtr;
  18.     int        ioVRefNum;
  19.     int        ioRefNum;
  20.     int        csCode;
  21.     long        lParam1;
  22.     long        lParam2;
  23.     long        lParam3;
  24. /*    ^^^^        */
  25. } PrParam;
  26. #define    WIDTH    164        /* la bombe if not a multiple of 4 */
  27. #define    NROWS    66        /* 11 inches * lines per inch. */
  28. typedef struct bauds{
  29.     int    rate;
  30.     char label[10];
  31. }BAUDS;
  32. typedef struct{
  33.     int    dirty;
  34.     unsigned char    text[WIDTH];
  35. }line,*pline,**hline;
  36. typedef struct{
  37.     int    dummy[5];
  38. } pconfig,*Pcfg,**Pfg;
  39. /* Be a real Mac cowboy, access data by the handle. */
  40. #define pport         ((*settings)->dummy[0])
  41. #define pbaud         ((*settings)->dummy[1])
  42. #define XonXoff        ((*settings)->dummy[2])
  43. /* Yeeeeee-Hah !! I don't even lock it! */
  44. typedef struct {            /* Structure description of STR# */
  45.     int    numstrings;        /* resource. */
  46.     unsigned char    thestrings[];
  47. }stringlist,**StrList;
  48. #define RES1ID    (-4080)
  49. #define RES2ID    (-8192)
  50. #define ILLEGAL    0x4AFC
  51. typedef unsigned char Str36[36];
  52. #define HREZZ    72
  53. #define    HREZZ10    60    /* For 10 cpi. */
  54. #define    HREZZ12    72    /* For 12 cpi. */
  55. #define    HREZZ15    90    /* For 15 cpi. */
  56. #define VREZZ    66    /* This gives us 6 lines of printed text per inch. */
  57. #define    lines_per_inch    6
  58. #define    CHARWIDTH    6
  59. #define CHARHEIGHT    11
  60.  
  61. #define    iPrPrivate    99
  62.  
  63. #define    VERSION        3
  64.  
  65. #define    _DEBUG    0
  66. #if    _DEBUG
  67. #define DEBUG    asm{\
  68.     Debugger\
  69. }
  70. #else
  71. #define DEBUG
  72. #endif
  73. #define IDEV10    0xFD01
  74. #define IDEV12    0xFD02
  75. #define IDEV15    0xFD03
  76. /* HIgh order byte of IDEV is -3 for printer driver, low order byte is
  77.  * device specific.  I use it to determine character pitch for daisy wheel
  78.  * devices and dot matrix in draft mode.
  79.  */
  80. #define SETUP_CMD    'Setp'
  81. #define PRINT_CMD    'Prnt'
  82. #define    CLOSE_CMD    'Clos'
  83. #define    OPEN_CMD    'Open'
  84.  
  85. typedef    struct{        /* Font characterization table for use by the */
  86.     int        vres;            /* Font Manager. */
  87.     int        hres;
  88.     SignedByte    bold[3];
  89.     SignedByte    italic[3];
  90.     SignedByte    notused[3];
  91.     SignedByte    outline[3];
  92.     SignedByte    shadow[3];
  93.     SignedByte    condensed[3];
  94.     SignedByte    extended[3];
  95.     SignedByte    underline[3];
  96. }fontab;
  97.  
  98. /*
  99.  * Shared storage, defined and initialized by the driver code, accessed
  100.  * elsewhere.
  101.  */
  102. #ifdef DRIVER_MODULE
  103. #else
  104. typedef struct{
  105. #endif
  106. #ifdef DRIVER_MODULE
  107. BAUDS    mybauds[] = {            /* Baud rate constant table. */
  108.     { baud300,    "\p300"},    /* Should use a string list. */
  109.     { baud600,    "\p600"},    /* But these are numbers, so I */
  110.     { baud1200,    "\p1200"},    /* Think it's OK. */
  111.     { baud1800,    "\p1800"},    /* This has to be the FIRST */
  112.     { baud2400,    "\p2400"},    /* driver global to be declared, */
  113.     { baud3600,    "\p3600"},    /* since it is also used by our */
  114.     { baud4800,    "\p4800"},    /* PACK -4096 resource, which  */
  115.     { baud7200,    "\p7200"},    /* needs to find it at the head */
  116.     { baud9600,    "\p9600"},    /* of PREC -8192. */
  117.     { baud19200,    "\p19200"}
  118. };                
  119. Pfg    settings = nil;
  120. static    PrParam prpb = {
  121.     nil,            /* qLink     */
  122.     0,            /* qType     */
  123.     0,            /* ioTrap     */
  124.     nil,            /* ioCmdAddr     */
  125.     nil,            /* ioCompletion */
  126.     0,            /* ioResult     */
  127.     nil,            /* ioNamePtr     */
  128.     0,            /* ioVRefNum     */
  129.     iPrDrvrRef,        /* ioRefNum     */
  130.     0,            /* csCode     */
  131.     0L,0L,0L        /* lParam[1-3]     */
  132. };
  133. Str36    prname = sPrDrvr;
  134. #else
  135.     BAUDS    mybauds[10];
  136.     Pfg    settings;
  137.     PrParam    prpb;
  138. Str36    prname;
  139. #endif
  140.     ParamBlockRec     iopb;        /* For writing to the serial driver. */
  141. #ifdef DRIVER_MODULE
  142.     static int phone   =       FALSE;
  143.     static int printer =     FALSE;
  144. #else
  145.     int phone;
  146.     int printer;
  147. #endif
  148.     int    drivernum;        /* RefNum of serial driver to use. */
  149.     Str255    prinitstr;
  150.     Str36    prlfstr;
  151.     Str36    prtopstr;
  152.     Str36    preopstr;
  153.     Str36    preofstr;
  154. #ifdef DRIVER_MODULE
  155. static fontab    myfonts = { 
  156.         VREZZ,
  157.         HREZZ12,
  158.     {    0,    2,    2},
  159.     {    1,    8,    2},
  160.     {    0,    0,    0},
  161.     {    5,    1,    2},
  162.     {    5,    2,    4},
  163.     {    0,    0,    -2},
  164.     {    0,    0,    2},
  165.     {    1,    3,    2}
  166. };
  167. static Point noscale = {0x0001,0x0001};
  168. #else
  169.     fontab    myfonts;
  170.     int    MyRes[3];
  171.     Point    noscale;
  172. #endif
  173.     Str255    stringbuf;
  174.     int    topmargin,nlines;
  175.     TPrint    Print;
  176.     int    pagenum;
  177.     SysEnvRec theWorld;
  178. #ifdef DRIVER_MODULE
  179. #else
  180. }Dstorage,*DPstorage,**DHstorage;
  181. #endif
  182. #define SHEETDIALOG    (-8193)
  183. #define    DONEITEM    1
  184. #define    STOPITEM    2
  185.  
  186.